package com.lovo.ssc.controller;


import com.lovo.ssc.entity.BuyPlan;
import com.lovo.ssc.service.IBuyPlanService;
import com.lovo.sscsys.dto.buyPlanMQDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.w3c.dom.stylesheets.LinkStyle;

import java.util.List;

/**
 * <p>
 * 采购表 前端控制器
 * </p>
 *
 * @author lovo
 * @since 2022-07-07
 */
@RestController
@RequestMapping("/buyplan")
@Slf4j
@Api(tags = "采购计划控制器")
public class BuyPlanController {
    //1.本地采购计划
    @Autowired
    IBuyPlanService service;

    /**
     * 1.查询全部采购计划
     *
     * @return
     */
    /**
     * wwww
     * @return
     */
    @ApiOperation(value = "查询全部采购计划")
    @GetMapping("findAllPlan")
    public List<BuyPlan> findAllPlan() {
        List<BuyPlan> list=   service.list();
        log.info(list.toString());
        return list;
    }

    /**
     * 2.添加采购计划
     *
     * @return
     */
    @ApiOperation(value = "新增采购计划")
    @PostMapping("addPlan")
    public String addPlan(buyPlanMQDto dto ) {
        BuyPlan buyPlan=new BuyPlan();
        buyPlan.setNum(dto.getNum());
        buyPlan.setGoodsName(dto.getGoodsName());
        //plus可能存在异常
        buyPlan.setBuyId(4);
       service.saveOrUpdate(buyPlan);
        log.info("-------新增采购计划--------");

        return "ok";

    }
    /**
     * 3.修改库存商品阈值
     *
     * @return
     */
    @ApiOperation(value = "修改库存商品阈值")
    @PutMapping("updateScope")
    public String updateScope(Integer id,Integer newScope) {

        return "ok";
    }


}
